<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery.min.js"></script>
</head>
<body>
    <input type="text">
    <select name="" id="select">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*" selected="selected">*</option>
        <option value="/">/</option>
    </select>
    <input type="text">
    <input type="button" value="=">
    <input type="text">
    <script>
        const $numbers = $(":text:not(:last)"), $button = $(":button"), $result = $(":input:last"); 
        $button.click(() => {
            let sum;
            if (/^(\-|\+)?\d+(\.\d+)?$/.test($numbers.val())) {
                $numbers.css("background","")
                $option = $(":selected").val();
                switch ($option) {
                    case "+":
                    sum = parseInt($numbers.eq(0).val()) + parseInt($numbers.eq(1).val());
                    break;
                    case "-":
                    sum = parseInt($numbers.eq(0).val()) - parseInt($numbers.eq(1).val());
                    break;
                    case "*":
                    sum = parseInt($numbers.eq(0).val()) * parseInt($numbers.eq(1).val());
                    break;
                    case "/":
                    sum = parseInt($numbers.eq(0).val()) / parseInt($numbers.eq(1).val());
                }
            } else {
                $numbers.val("请输入数字").css("background","red")
            }
            $result.val(sum)
        })
    </script>
</body>
</html>